<?php
declare (strict_types=1);

namespace app\user\service\user;

use app\common\service\BaseService;
use app\user\logic\user\Income as IncomeLogic;
use app\user\logic\user\IncomeFlow;
use think\facade\Request;
use think\Response;

/**
 * 用户个人中心接口类
 */
class Income extends BaseService
{

    public function basic(): Response
    {
        $data = app(IncomeLogic::class)->basic();

        return $this->parseToData($data, 1, '获取成功');
    }

    /**
     * 收入明细
     * Author 亓官雨树<lucky.max@foxmail.com>
     * Date：   2020-05-22
     */
    public function flow(): Response
    {
        $param = Request::get();
        $flow  = app(IncomeFlow::class)->flow($param);
        return $this->parseToData($flow, 1, '获取成功');
    }

    /**
     * 推广课程带来的收益
     * Author 亓官雨树<lucky.max@foxmail.com>
     * Date：   2021-05-19
     */
    public function courseIncome(): Response
    {
        $flow  = app(IncomeFlow::class)->courseIncome();
        return $this->parseToData($flow, 1, '获取成功');
    }

    /**
     * 推广用户带来的收益
     * Author 亓官雨树<lucky.max@foxmail.com>
     * Date：   2021-05-19
     */
    public function userIncome(): Response
    {
        $flow  = app(IncomeFlow::class)->userIncome();
        return $this->parseToData($flow, 1, '获取成功');
    }

    public function toBalance(): Response
    {
        $param = Request::post();
        $data  = app(IncomeLogic::class)->toBalance($param);

        return $this->parseToData($data, 1, '提交成功');
    }

    public function toWxpay(): Response
    {
        $param = Request::post();
        $data  = app(IncomeLogic::class)->toWxpay($param);

        return $this->parseToData($data, 1, '提交成功');
    }

    public function toWxpayPcOpenid(): Response
    {
        app(IncomeLogic::class)->toWxpayPcOpenid();

        return $this->parseToData([], 1, '提交成功');
    }

    public function toWxpayPcCheck(): Response
    {
        $data  = app(IncomeLogic::class)->toWxpayPcCheck();

        return $this->parseToData($data, 1, '提交成功');
    }

    public function toAlipay(): Response
    {
        $param = Request::post();
        $data  = app(IncomeLogic::class)->toAlipay($param);

        return $this->parseToData($data, 1, '提交成功');
    }
}
